<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<script src="/admin/xadmin/lib/layui/upload.js" charset="utf-8"></script>

<body>
<div class="x-body">
    <form class="layui-form" lay-filter="formAjax">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>平台类型
            </label>
            <div id="pMenu" style="width:100%;flex:1"></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>名称
            </label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name" placeholder="用户名" required="required"
                       lay-verify="required" autocomplete="off" class="layui-input" value=""/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>app_id
            </label>
            <div class="layui-input-block">
                <input type="text" name="app_id" id="app_id" placeholder="app_id" required="required"
                       lay-verify="required" autocomplete="off" class="layui-input" value=""/>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>app_secret
            </label>
            <div class="layui-input-block">
                <input type="text" name="app_secret" id="app_secret" placeholder="app_secret" required="required"
                       lay-verify="required" autocomplete="off" class="layui-input" value=""/>

            </div>
        </div>

        <input type="hidden" name="id" id="id" value=""/>
        <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;"/>
    </form>
</div>
<script>
    let params = {
        addUrl: '/admin/partner/add',
        editUrl: '/admin/partner/edit',
        detailUrl: '/admin/partner/detail',
    }
    form_ajax(params)
    let id = GetQueryString('id')
    let selectParams = {
        url: '/admin/partner/type',
        selected: [],
        tips: '类型',
        name: 'type',
        field_id: 'id',
        field_Name: 'name',
        elem: '#pMenu'
    }

    if (id) {
        Ajax(params.detailUrl, {id}).then(result => {
            selectParams.selected = result.data.type.toString()
            selectN(selectParams)

        });
    } else {
        selectN(selectParams)
    }

</script>
</body>

</html>